package com.wdb.modules.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wdb.modules.system.domain.Menu;
import com.wdb.modules.system.domain.vo.MenuQueryCriteria;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * @author: wendaobai@qq.com
 * @date: 2024/1/22 0022 10:30
 */
@Mapper
public interface MenuMapper extends BaseMapper<Menu> {
  List<Menu> findByRoleIdsAndTypeNot(@Param("roleIds") Set<Long> roleIds, @Param("type") int i);

  List<Menu> findAll(@Param("criteria") MenuQueryCriteria menuQueryCriteria);

  List<Menu> findByPidOrderByMenuSort(@Param("pid") Long pid);

  List<Menu> findByPidIsNullOrderByMenuSort();

  Menu findByTitle(@Param("title") String title);

  Menu findByComponentName(@Param("name") String componentName);

  @Select("update sys_menu set sub_count = #{subCount} where menu_id = #{id}")
  void updateSubCntById(Long id, int subCount);

  @Select("select count(*) from sys_menu  where pid=#{id} ;")
  int countByPid(Long id);
}
